package cn.star.jots.director.controller;

import cn.star.jots.base.response.JsonResult;
import cn.star.jots.director.pojo.dto.DirectorQuery;
import cn.star.jots.director.pojo.dto.DirectorSaveParam;
import cn.star.jots.director.pojo.vo.DirectorVO;
import cn.star.jots.director.service.DirectorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/director")
@Api(tags = "导演管理")
@Slf4j
public class DirectorController {

    @Autowired
    DirectorService directorService;

    @GetMapping("/select")
    @ApiOperation(value = "查询导演信息")
    public JsonResult selectAll(DirectorQuery directorQuery) {
        log.info("查询导演信息:directorQuery={}", directorQuery);
        List<DirectorVO> list = directorService.selectAll(directorQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("/save")
    @ApiOperation(value = "保存导演信息")
    public JsonResult save(DirectorSaveParam directorSaveParam) {
        log.info("保存导演信息:directorVO={}", directorSaveParam);
        directorService.save(directorSaveParam);
        return JsonResult.ok();
    }


    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "根据ID删除导演信息")
    public JsonResult deleteById(@PathVariable Long id) {
        log.info("删除导演信息:id={}", id);
        directorService.deleteById(id);
        return JsonResult.ok();
    }
}
